package com.yc.txx.servlet;

import com.google.gson.Gson;
import com.yc.txx.vo.Result;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "MyInfoServlet", value = "/MyInfoServlet.s")
public class MyInfoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        final Object myinfo = request.getSession().getAttribute("myinfo");
        Result result;
        if(myinfo== null){
            result = Result.failure("未登录");
        } else {
            result = Result.success("已登录",myinfo);
        }
        final String json = new Gson().toJson(result);
        response.getWriter().append(json);
    }

}
